//
//  FQDColumnCrossLineLabel.m
//  FakeQDaily
//
//  Created by mewxiv on 9/23/16.
//  Copyright © 2016 Xensius. All rights reserved.
//

#import "FQDColumnCrossLineLabel.h"
#import "Masonry.h"

@interface FQDColumnCrossLineLabel ()

@property (nonatomic, strong) UIView *crossLine;
@property (nonatomic, strong) UILabel *label;

@end

@implementation FQDColumnCrossLineLabel

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self prepareUI];
    }
    return self;
}

- (void)prepareUI
{
    _crossLine = [[UIView alloc] init];
    _crossLine.backgroundColor = RGB(244, 244, 244);
    [self addSubview:_crossLine];
    
    _label = [[UILabel alloc] init];
    _label.font = FQDRegularFontWithSize(14.0f);
    _label.textColor = RGB(148, 148, 148);
    _label.textAlignment = NSTextAlignmentCenter;
    _label.numberOfLines = 0;
    _label.backgroundColor = [UIColor whiteColor];
    [self addSubview:_label];
    
    WeakSelf;
    [_crossLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.mas_centerY);
        make.left.equalTo(weakSelf);
        make.width.equalTo(weakSelf);
        make.height.equalTo(@1);
    }];
    
    [_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(weakSelf);
        make.height.equalTo(@17);
    }];
}

- (void)setLabelText:(NSString *)text
{
    NSString *trailingText = [NSString stringWithFormat:@"  %@  ", text];
    self.label.text = trailingText;
}

- (NSString *)labelText
{
    return self.label.text;
}

@end
